package com.bw.trans;

import com.bw.bean.WaterSensor;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;

/**
 * @ClassName: TransMap
 * @Author: huzx
 * @Date: 2025-01-07 10:53
 * @Version: 1.0
 **/
public class TransMap {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        DataStreamSource<WaterSensor> ds = env.fromElements(
                new WaterSensor("w1", 1L, 1),
                new WaterSensor("w2", 2L, 2),
                new WaterSensor("w3", 3L, 3),
                new WaterSensor("w4", 4L, 4),
                new WaterSensor("w5", 5L, 5)
        );
//        ds.print();

//        ds.map(new MapFunction<WaterSensor, String>() {
//            @Override
//            public String map(WaterSensor value) throws Exception {
//                return value.getId();
//            }
//        }).print();

        ds.map(sener->sener.getId()).print();

        env.execute();
    }
}
